<html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"><title>CatchSprite</title></head>
<body bgcolor="#FFFFDF" link="#009999" vlink="#006666" alink="#006666">
<font face="Arial" size="2"><p align="center"><b><font size="4">CatchSprite()</font></b></p>
<p><b>Syntax</b></p><blockquote>

Result = <font color="#006666"><b>CatchSprite</b></font>(#Sprite, *MemoryAddress [, Mode])</blockquote>

<b>Description</b><br><blockquote>



Loads the specified sprite from the given memory area. 
A screen should be opened with <a href="../screen/openscreen.html">OpenScreen()</a> or <a href="../screen/openwindowedscreen.html">OpenWindowedScreen()</a> before loading a sprite. 
Sprites can be in BMP format or any other format supported by the <a href="../imageplugin/index.html">ImagePlugin library</a>. 
A catched sprite can be freed by using the <a href="freesprite.html">FreeSprite()</a> function. The 'CatchSprite' function is useful when 
using the '<a href="../reference/includes.html">IncludeBinary</a>' PureBasic keyword. The images can be packed inside 
the executable. Nevertheless, use this option very carefully, as it will take 
more memory than storing the file in an external file (the file will be in both 
executable memory and loaded into physical memory). 
<br>
<br>
The following functions can be used to enable automatically more image formats: 
<br>
<a href="../imageplugin/usejpegimagedecoder.html">UseJPEGImageDecoder()</a> 
<br>
<a href="../imageplugin/usejpeg2000imagedecoder.html">UseJPEG2000ImageDecoder()</a> 
<br>
<a href="../imageplugin/usepngimagedecoder.html">UsePNGImageDecoder()</a> 
<br>
<a href="../imageplugin/usetiffimagedecoder.html">UseTIFFImageDecoder()</a> 
<br>
<a href="../imageplugin/usetgaimagedecoder.html">UseTGAImageDecoder()</a> 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Sprite</i></td>
<td width="90%"> 
 
A number to identify the new sprite. <a href="../reference/purebasic_objects.html">#PB_Any</a> can 
be used to auto-generate this number. 

 

</td></tr>
<tr><td><i>*MemoryAddress</i></td>
<td> 
 
The memory address holding the image used to create the sprite. 

 

</td></tr>
<tr><td><i>Mode (optional)</i></td>
<td> 
 
It can be a combination of the following values (with the '|' operator): 
 
<pre><font face="Courier New, Courier, mono"size="2">  <font color="#924B72">#PB_Sprite_PixelCollision</font>: Add special information to handle pixel collision trough <a href="spritepixelcollision.html">SpritePixelCollision()</a>.
  <font color="#924B72">#PB_Sprite_AlphaBlending</font> : Sprite is created with per pixel alpha-channel support, needed for <a href="displaytransparentsprite.html">DisplayTransparentSprite()</a>.
                              The image format has to support it (only PNG and TIFF for now).
</font></pre>

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>



Nonzero if the sprite has been created, zero otherwise. If <font color="#924B72">#PB_Any</font> was used 
for the #Sprite parameter then the generated number is returned on success. 

 

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <b><font color="#006666">Debug</font></b> <font color="#006666">CatchSprite</font>(0, ?Pic)

<b><font color="#006666">DataSection</font></b>
  Pic: 
    <b><font color="#006666">IncludeBinary</font></b> "Sprite.bmp"
<b><font color="#006666">EndDataSection</font></b>
</font></pre>

</blockquote><p><b>Remarks</b></p><blockquote>



The "?" is a pointer to a label. More information about pointers and memory access can be found 
in the relating chapter <a href="../reference/memory.html">here</a>. 

 

</blockquote><p><b>See Also</b></p><blockquote>

<a href="createsprite.html">CreateSprite()</a>, <a href="loadsprite.html">LoadSprite()</a> 

</Blockquote><p><b>Supported OS  </b><Blockquote>All</Blockquote></p><center><a href=index.html>Sprite Index</a> - <a href=clipsprite.html>ClipSprite()</a> -&gt;



</body></html>